// import HomeLayout from "./components/layout/Home.tsx";
import {Suspense, useEffect} from "react";
import {createBrowserRouter, RouterProvider} from "react-router-dom";
import Routes from "@src/config/routes.tsx";
import LoadingPage from "@src/pages/loading";
import {Toaster} from 'react-hot-toast';
import {getUserInfo} from "@src/utils/userInfo"

function App() {
    const {user} = getUserInfo()
    useEffect(() => {
        if (location.pathname != "/") {
            if (!location.pathname.includes("/login")) {
                if (user?.isVisitor) {
                    localStorage.removeItem("UserData");
                    location.pathname = "/login"
                }
            }
        }
    }, []);
    return (
        <div className="dark App">
            <Suspense fallback={<LoadingPage fullScreen/>}>
                <RouterProvider router={createBrowserRouter(Routes)}/>
            </Suspense>
            <Toaster></Toaster>
        </div>
    )
}


export default App
